﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace ExamSharedClasses
{
    /// <summary>
    /// (k) UserDetails ist die Spezialisierung von User, die zusätzlich
    /// Namen, Vornamen, Gebutsdatum und Geschlecht enthält...
    /// </summary>
    [Serializable()]
    public class UserDetails : User
    {
        public const string USER_NAME = "user_name";
        public const string USER_SURNAME = "user_surname";
        public const string USER_BIRTHDAY = "user_birthday";
        public const string USER_SEX = "user_sex";

        public string UserName { get; set; }
        public string UserSurName { get; set; }
        public DateTime UserBirthDate { get; set; }
        public bool UserSex { get; set; }

        public UserDetails() : base() {
            this.UserName = "";
            this.UserSurName = "";
            this.UserBirthDate = new DateTime();
            this.UserSex = true;
        }
        public UserDetails(string userEmail) : base(userEmail)
        {
            this.UserName = "";
            this.UserSurName = "";
            this.UserBirthDate = new DateTime();
            this.UserSex = true;
        }
        public UserDetails(int userId, UserGroup userGroup, string userName, string userSurName, string userEmail, DateTime userBirthday, bool userSex)
        : base (userId, userGroup, userEmail)
        {
            this.UserName = userName;
            this.UserSurName = userSurName;
            this.UserBirthDate = userBirthday;
            this.UserSex = userSex;
        }
        public UserDetails( UserDetails ud )
            : this( ud.UserId, ud.UserGroup, ud.UserName, ud.UserSurName, ud.UserEmail, ud.UserBirthDate, ud.UserSex ) { }

        public override string ToString() {
            StringBuilder sb = new StringBuilder( base.ToString() + "UserDetails: " );
            if ( UserName != null )
                sb.Append( '\t' + UserName.ToString() + ", " );
            if ( UserSurName != null )
                sb.Append( '\t' + UserSurName.ToString() + ", " );
            if ( UserBirthDate != null )
                sb.Append( '\t' + UserBirthDate.ToString() + ", " );
            sb.Append( '\t' + UserSex.ToString() + '\n' );
            
            return sb.ToString();
        }

        public override string ToMoreDetailedString() {
            StringBuilder sb = new StringBuilder( base.ToMoreDetailedString());// + "[userDetails]\n" );
            if ( UserName != null && UserSurName != null )
                sb.Append( "Name: "  + UserName.ToString() + " " + UserSurName.ToString() + '\n' );
            if ( UserBirthDate != null )
                sb.Append( "geboren am: " + UserBirthDate.ToLongDateString() + ", " );
            sb.Append( (UserSex? "männlich" : "weiblich") + "\n\n" );
            return sb.ToString();
        }
    }
}
